package util;

import java.util.ArrayList;
import java.util.Random;

import logging.Logger;

public class ShuffleUtil<Item> {

	public ArrayList<Item> Shuffle( ArrayList<Item> list, String seed )
	{
		ArrayList<Item> shuffled = new ArrayList<Item>();
		int[] shuffleArray = new int[list.size()];
		Random r = new Random();
		
		
		for( int i=0; i<list.size(); i++ )
			shuffleArray[i] = i;
		
		String check = "";
		for( int i = 0; i < list.size(); i++ )
		{
			int point = i + Math.abs(r.nextInt()%(list.size()-i));
			Logger.getInstance().log(Logger.DETAIL, "Shuffle: " + point);
			int hold = shuffleArray[i];
			shuffleArray[i] = shuffleArray[point];
			shuffleArray[point] = hold;
		}
		
		for( int i = 0; i<shuffleArray.length; i++ )
		{
			check = check + " " + shuffleArray[i];
			shuffled.add(list.get(shuffleArray[i]));
		}
		
		Logger.getInstance().log(Logger.DETAIL, "Array: " + check);
		
		return shuffled;
	}
}
